<template>
	<view style="padding: 20rpx;">
		<view style="margin-bottom: 10rpx;">
			<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
				activeColor="#ff9900">
			</uni-segmented-control>
		</view>
		<view style="padding: 20rpx;">
			<view v-show="current===0">
				<view class="box" v-for="item in ordersList" style="margin-top: 10px;" @click="goOrderDetail(item.id)">
					<view style="display: flex;">
						<view style="flex: 3; font-size: 16px;font-weight: bold;"  @click.native.stop="goBusinessDetail(item.businessId)">{{item.businessName}}></view>
						<view v-if="item.status === '待评价'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">等待买家评价</view>
						<view v-if="item.status === '待付款'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">等待付款中</view>
						<view v-if="item.status === '待发货'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">买家已付款</view>
						<view v-if="item.status === '待收货'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">卖家已发货</view>
					</view>
					<view style="margin-top: 10px;">
						<view style="display: flex;">
							<image :src="item.medicinesPhoto" style="width: 200rpx;margin-top: 6px;" mode="widthFix">
							</image>
							<view>
								<view style="display: flex;">
									<view>
										<view
											style="font-size: 18px; font-weight: bold; width: 190px;margin-left: 10px;margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
											{{item.medicinesName }}
										</view>
										<view
											style="font-size: 14px; font-weight: bold;margin-left: 10px;color: gray;margin-top:8px;">
											样式规格:{{item.styleDescribe }}
										</view>
									</view>
									<view style="margin-top: 5px;">
										<view style="font-size: 15px;font-weight: bold;">￥{{item.totalPrice }}</view>
										<view style="font-size: 15px;font-weight: bold;display: flex;">
											<view style="display: flex;text-align: center;margin-top: 6px;">
												<image src="../../static/icons/叉.png"
													style="width: 20rpx;margin-top: 5px;" mode="widthFix">
												</image>
												<view>{{item.num}}</view>
											</view>
										</view>
									</view>
								</view>
								<view style="display: flex;font-size: 12px;margin-left: 5px;margin-top: 3px;">
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										假一赔四
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										退货宝
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px; border: 1px solid orange;color: orange;padding: 2px;">
										极速退款
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										七天无理由退货
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="square-box"
						style="background-color:#E1E1E1;border: 1px solid #E1E1E1;margin-top: 2px;width: 100%;padding: 2px;display: flex;">
						<image v-if="item.status === '待付款'" src="../../static/icons/时间.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待发货'" src="../../static/icons/拣货中.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待收货'" src="../../static/icons/小货车.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待评价'" src="../../static/icons/签收.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<view v-if="item.status === '待付款'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">订单即将关闭，建议尽快付款
						</view>
						<view v-if="item.status === '待发货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">
							商家正在拣货中，最迟24小时内发货</view>
						<view v-if="item.status === '待收货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">运输中 预计11月24日送达
						</view>
						<view v-if="item.status === '已完成'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">您的快件已签收，签收人张老三
						</view>
						<!-- 如果需要处理'待评价'状态，可以添加如下代码 -->
						<view v-if="item.status === '待评价'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">您的订单已完成，欢迎评价
						</view>

					</view>
					<view style="display: flex;margin-top: 5px;gap: 5px;">
						<button size="mini"
							style="border-radius: 15px;margin-left: 40px;background-color: white;border: 1px solid #E1E1E1;"
							@click.native.stop='addCart(item)'>加入购物</button>
						<button size="mini"
							style="border-radius: 15px;background-color: white;border: 1px solid #E1E1E1;"
							@click.native.stop='chat(item.businessId)'>联系客服</button>
						<button v-if="item.status === '待付款'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="updatePay(item)">继续付款</button>
						<button v-if="item.status === '待发货'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop='toggle'>催促发货</button>
						<button v-if="item.status === '待收货'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="updateStatus(item, '待评价')">确认收货</button>
						<button v-if="item.status === '待评价'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="goCommentDetail(item,'已完成')">进行评价</button>
						<button v-if="item.status === '已完成'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							disabled>订单完成</button>
					</view>
				</view>
			</view>
			<view v-show="current===1">
				<view class="box" v-for="item in ordersList" style="margin-top: 10px;" @click="goOrderDetail(item.id)">
					<view style="display: flex;">
						<view style="flex: 3; font-size: 16px;font-weight: bold;"  @click.native.stop="goBusinessDetail(item.businessId)">{{item.businessName}}></view>
						<view v-if="item.status === '待评价'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">等待买家评价</view>
						<view v-if="item.status === '待付款'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">等待付款中</view>
						<view v-if="item.status === '待发货'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">买家已付款</view>
						<view v-if="item.status === '待收货'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">卖家已发货</view>
					</view>
					<view style="margin-top: 10px;">
						<view style="display: flex;">
							<image :src="item.medicinesPhoto" style="width: 200rpx;margin-top: 6px;" mode="widthFix">
							</image>
							<view>
								<view style="display: flex;">
									<view>
										<view 
											style="font-size: 18px; font-weight: bold; width: 190px;margin-left: 10px;margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
											{{item.medicinesName }}
										</view>
										<view
											style="font-size: 14px; font-weight: bold;margin-left: 10px;color: gray;margin-top:8px;">
											样式规格:{{item.styleDescribe }}
										</view>
									</view>
									<view style="margin-top: 5px;">
										<view style="font-size: 15px;font-weight: bold;">￥{{item.totalPrice }}</view>
										<view style="font-size: 15px;font-weight: bold;display: flex;">
											<view style="display: flex;text-align: center;margin-top: 6px;">
												<image src="../../static/icons/叉.png"
													style="width: 20rpx;margin-top: 5px;" mode="widthFix">
												</image>
												<view>{{item.num}}</view>
											</view>
										</view>
									</view>
								</view>
								<view style="display: flex;font-size: 12px;margin-left: 5px;margin-top: 3px;">
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										假一赔四
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										退货宝
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px; border: 1px solid orange;color: orange;padding: 2px;">
										极速退款
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										七天无理由退货
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="square-box"
						style="background-color:#E1E1E1;border: 1px solid #E1E1E1;margin-top: 2px;width: 100%;padding: 2px;display: flex;">
						<image v-if="item.status === '待付款'" src="../../static/icons/时间.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待发货'" src="../../static/icons/拣货中.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待收货'" src="../../static/icons/小货车.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待评价'" src="../../static/icons/签收.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<view v-if="item.status === '待付款'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">订单即将关闭，建议尽快付款
						</view>
						<view v-if="item.status === '待发货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">
							商家正在拣货中，最迟24小时内发货</view>
						<view v-if="item.status === '待收货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">运输中 预计11月24日送达
						</view>
						<view v-if="item.status === '待收货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">您的快件已签收，签收人张老三
						</view>
						<!-- 如果需要处理'待评价'状态，可以添加如下代码 -->
						<view v-if="item.status === '待评价'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">您的订单已完成，欢迎评价
						</view>

					</view>
					<view style="display: flex;margin-top: 5px;gap: 5px;">
						<button size="mini"
							style="border-radius: 15px;margin-left: 40px;background-color: white;border: 1px solid #E1E1E1;"
							@click.native.stop='addCart(item)'>加入购物</button>
						<button size="mini"
							style="border-radius: 15px;background-color: white;border: 1px solid #E1E1E1;"
							@click.native.stop='chat(item.businessId)'>联系客服</button>
						<button v-if="item.status === '待付款'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="updatePay(item)">继续付款</button>
						<button v-if="item.status === '待发货'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop='toggle'>催促发货</button>
						<button v-if="item.status === '待收货'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="updateStatus(item, '待评价')">确认收货</button>
						<button v-if="item.status === '待评价'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="goCommentDetail(item,'已完成')">进行评价</button>
						<button v-if="item.status === '已完成'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							disabled>订单完成</button>
					</view>
				</view>
			</view>
			<view v-show="current===2">
				<view class="box" v-for="item in ordersList" style="margin-top: 10px;" @click="goOrderDetail(item.id)">
					<view style="display: flex;">
						<view style="flex: 3; font-size: 16px;font-weight: bold;" @click.native.stop="goBusinessDetail(item.businessId)">{{item.businessName}}></view>
						<view v-if="item.status === '待评价'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">等待买家评价</view>
						<view v-if="item.status === '待付款'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">等待付款中</view>
						<view v-if="item.status === '待发货'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">买家已付款</view>
						<view v-if="item.status === '待收货'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">卖家已发货</view>
					</view>
					<view style="margin-top: 10px;">
						<view style="display: flex;">
							<image :src="item.medicinesPhoto" style="width: 200rpx;margin-top: 6px;" mode="widthFix">
							</image>
							<view>
								<view style="display: flex;">
									<view>
										<view 
											style="font-size: 18px; font-weight: bold; width: 190px;margin-left: 10px;margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
											{{item.medicinesName }}
										</view>
										<view
											style="font-size: 14px; font-weight: bold;margin-left: 10px;color: gray;margin-top:8px;">
											样式规格:{{item.styleDescribe }}
										</view>
									</view>
									<view style="margin-top: 5px;">
										<view style="font-size: 15px;font-weight: bold;">￥{{item.totalPrice }}</view>
										<view style="font-size: 15px;font-weight: bold;display: flex;">
											<view style="display: flex;text-align: center;margin-top: 6px;">
												<image src="../../static/icons/叉.png"
													style="width: 20rpx;margin-top: 5px;" mode="widthFix">
												</image>
												<view>{{item.num}}</view>
											</view>
										</view>
									</view>
								</view>
								<view style="display: flex;font-size: 12px;margin-left: 5px;margin-top: 3px;">
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										假一赔四
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										退货宝
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px; border: 1px solid orange;color: orange;padding: 2px;">
										极速退款
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										七天无理由退货
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="square-box"
						style="background-color:#E1E1E1;border: 1px solid #E1E1E1;margin-top: 2px;width: 100%;padding: 2px;display: flex;">
						<image v-if="item.status === '待付款'" src="../../static/icons/时间.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待发货'" src="../../static/icons/拣货中.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待收货'" src="../../static/icons/小货车.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待评价'" src="../../static/icons/签收.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<view v-if="item.status === '待付款'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">订单即将关闭，建议尽快付款
						</view>
						<view v-if="item.status === '待发货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">
							商家正在拣货中，最迟24小时内发货</view>
						<view v-if="item.status === '待收货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">运输中 预计11月24日送达
						</view>
						<view v-if="item.status === '已完成'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">您的快件已签收，签收人张老三
						</view>
						<!-- 如果需要处理'待评价'状态，可以添加如下代码 -->
						<view v-if="item.status === '待评价'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">您的订单已完成，欢迎评价
						</view>

					</view>
					<view style="display: flex;margin-top: 5px;gap: 5px;">
						<button size="mini"
							style="border-radius: 15px;margin-left: 40px;background-color: white;border: 1px solid #E1E1E1;"
							@click.native.stop='addCart(item)'>加入购物</button>
						<button size="mini"
							style="border-radius: 15px;background-color: white;border: 1px solid #E1E1E1;"
							@click.native.stop='chat(item.businessId)'>联系客服</button>
						<button v-if="item.status === '待付款'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="updatePay(item)">继续付款</button>
						<button v-if="item.status === '待发货'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop='toggle'>催促发货</button>
						<button v-if="item.status === '待收货'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="updateStatus(item, '待评价')">确认收货</button>
						<button v-if="item.status === '待评价'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="goCommentDetail(item,'已完成')">进行评价</button>
						<button v-if="item.status === '已完成'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							disabled>订单完成</button>
					</view>
				</view>
			</view>
			<view v-show="current===3">
				<view class="box" v-for="item in ordersList" style="margin-top: 10px;" @click="goOrderDetail(item.id)">
					<view style="display: flex;">
						<view style="flex: 3; font-size: 16px;font-weight: bold;" @click.native.stop="goBusinessDetail(item.businessId)">{{item.businessName}}></view>
						<view v-if="item.status === '待评价'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">等待买家评价</view>
						<view v-if="item.status === '待付款'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">等待付款中</view>
						<view v-if="item.status === '待发货'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">买家已付款</view>
						<view v-if="item.status === '待收货'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">卖家已发货</view>
					</view>
					<view style="margin-top: 10px;">
						<view style="display: flex;">
							<image :src="item.medicinesPhoto" style="width: 200rpx;margin-top: 6px;" mode="widthFix">
							</image>
							<view>
								<view style="display: flex;">
									<view>
										<view 
											style="font-size: 18px; font-weight: bold; width: 190px;margin-left: 10px;margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
											{{item.medicinesName }}
										</view>
										<view
											style="font-size: 14px; font-weight: bold;margin-left: 10px;color: gray;margin-top:8px;">
											样式规格:{{item.styleDescribe }}
										</view>
									</view>
									<view style="margin-top: 5px;">
										<view style="font-size: 15px;font-weight: bold;">￥{{item.totalPrice }}</view>
										<view style="font-size: 15px;font-weight: bold;display: flex;">
											<view style="display: flex;text-align: center;margin-top: 6px;">
												<image src="../../static/icons/叉.png"
													style="width: 20rpx;margin-top: 5px;" mode="widthFix">
												</image>
												<view>{{item.num}}</view>
											</view>
										</view>
									</view>
								</view>
								<view style="display: flex;font-size: 12px;margin-left: 5px;margin-top: 3px;">
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										假一赔四
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										退货宝
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px; border: 1px solid orange;color: orange;padding: 2px;">
										极速退款
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										七天无理由退货
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="square-box"
						style="background-color:#E1E1E1;border: 1px solid #E1E1E1;margin-top: 2px;width: 100%;padding: 2px;display: flex;">
						<image v-if="item.status === '待付款'" src="../../static/icons/时间.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待发货'" src="../../static/icons/拣货中.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待收货'" src="../../static/icons/小货车.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待评价'" src="../../static/icons/签收.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<view v-if="item.status === '待付款'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">订单即将关闭，建议尽快付款
						</view>
						<view v-if="item.status === '待发货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">
							商家正在拣货中，最迟24小时内发货</view>
						<view v-if="item.status === '待收货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">运输中 预计11月24日送达
						</view>
						<view v-if="item.status === '已完成'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">您的快件已签收，签收人张老三
						</view>
						<!-- 如果需要处理'待评价'状态，可以添加如下代码 -->
						<view v-if="item.status === '待评价'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">您的订单已完成，欢迎评价
						</view>

					</view>
					<view style="display: flex;margin-top: 5px;gap: 5px;">
						<button size="mini"
							style="border-radius: 15px;margin-left: 40px;background-color: white;border: 1px solid #E1E1E1;"
							@click.native.stop='addCart(item)'>加入购物</button>
						<button size="mini"
							style="border-radius: 15px;background-color: white;border: 1px solid #E1E1E1;"
							@click.native.stop='chat(item.businessId)'>联系客服</button>
						<button v-if="item.status === '待付款'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="updatePay(item)">继续付款</button>
						<button v-if="item.status === '待发货'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop='toggle'>催促发货</button>
						<button v-if="item.status === '待收货'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="updateStatus(item, '待评价')">确认收货</button>
						<button v-if="item.status === '待评价'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="goCommentDetail(item,'已完成')">进行评价</button>
						<button v-if="item.status === '已完成'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							disabled>订单完成</button>
					</view>
				</view>
			</view>
			<view v-show="current===4">
				<view class="box" v-for="item in ordersList" style="margin-top: 10px;" @click="goOrderDetail(item.id)">
					<view style="display: flex;">
						<view style="flex: 3; font-size: 16px;font-weight: bold;" @click.native.stop="goBusinessDetail(item.businessId)">{{item.businessName}}></view>
						<view v-if="item.status === '待评价'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">等待买家评价</view>
						<view v-if="item.status === '待付款'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">等待付款中</view>
						<view v-if="item.status === '待发货'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">买家已付款</view>
						<view v-if="item.status === '待收货'"
							style="flex: 1;color: orange;font-size: 14px;font-weight: bold;">卖家已发货</view>
					</view>
					<view style="margin-top: 10px;">
						<view style="display: flex;">
							<image :src="item.medicinesPhoto" style="width: 200rpx;margin-top: 6px;" mode="widthFix">
							</image>
							<view>
								<view style="display: flex;">
									<view>
										<view
											style="font-size: 18px; font-weight: bold; width: 190px;margin-left: 10px;margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
											{{item.medicinesName }}
										</view>
										<view
											style="font-size: 14px; font-weight: bold;margin-left: 10px;color: gray;margin-top:8px;">
											样式规格:{{item.styleDescribe }}
										</view>
									</view>
									<view style="margin-top: 5px;">
										<view style="font-size: 15px;font-weight: bold;">￥{{item.totalPrice }}</view>
										<view style="font-size: 15px;font-weight: bold;display: flex;">
											<view style="display: flex;text-align: center;margin-top: 6px;">
												<image src="../../static/icons/叉.png"
													style="width: 20rpx;margin-top: 5px;" mode="widthFix">
												</image>
												<view>{{item.num}}</view>
											</view>
										</view>
									</view>
								</view>
								<view style="display: flex;font-size: 12px;margin-left: 5px;margin-top: 3px;">
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										假一赔四
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										退货宝
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px; border: 1px solid orange;color: orange;padding: 2px;">
										极速退款
									</view>
									<view
										style="margin-top: 10rpx;margin-left: 2px;border: 1px solid orange;color: orange;padding: 2px;">
										七天无理由退货
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="square-box"
						style="background-color:#E1E1E1;border: 1px solid #E1E1E1;margin-top: 2px;width: 100%;padding: 2px;display: flex;">
						<image v-if="item.status === '待付款'" src="../../static/icons/时间.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待发货'" src="../../static/icons/拣货中.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待收货'" src="../../static/icons/小货车.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<image v-if="item.status === '待评价'" src="../../static/icons/签收.png"
							style="width: 40rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						<view v-if="item.status === '待付款'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">订单即将关闭，建议尽快付款
						</view>
						<view v-if="item.status === '待发货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">
							商家正在拣货中，最迟24小时内发货</view>
						<view v-if="item.status === '待收货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">运输中 预计11月24日送达
						</view>
						<view v-if="item.status === '待收货'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">您的快件已签收，签收人张老三
						</view>
						<!-- 如果需要处理'待评价'状态，可以添加如下代码 -->
						<view v-if="item.status === '待评价'"
							style="color: #FF8040; font-size: 15px; margin-top: 4px; margin-left: 4px;">您的订单已完成，欢迎评价
						</view>

					</view>
					<view style="display: flex;margin-top: 5px;gap: 5px;">
						<button size="mini"
							style="border-radius: 15px;margin-left: 40px;background-color: white;border: 1px solid #E1E1E1;"
							@click.native.stop='addCart(item)'>加入购物</button>
						<button size="mini"
							style="border-radius: 15px;background-color: white;border: 1px solid #E1E1E1;"
							@click.native.stop='chat(item.businessId)'>联系客服</button>
						<button v-if="item.status === '待付款'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="updatePay(item)">继续付款</button>
						<button v-if="item.status === '待发货'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop='toggle'>催促发货</button>
						<button v-if="item.status === '待收货'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="updateStatus(item, '待评价')">确认收货</button>
						<button v-if="item.status === '待评价'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							@click.native.stop="goCommentDetail(item,'已完成')">进行评价</button>
						<button v-if="item.status === '已完成'" size="mini"
							style="border-radius: 15px;color: #FF8040;border: 1px solid #FF8040;background-color: white;"
							disabled>订单完成</button>
					</view>
				</view>
			</view>
		</view>

		<view>
			<!-- 提示窗示例 -->
			<uni-popup ref="alertDialog" type="dialog">
				<uni-popup-dialog :type="msgType" cancelText="取消" confirmText="确认" title="删除确认" content="您确认删除订单吗？"
					@confirm="del">
				</uni-popup-dialog>
			</uni-popup>
			<!-- 保障弹窗 -->
			<uni-popup ref="popup" background-color="#fff" @change="change">
				<view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
					<view style="padding: 10px;height: 250px;" class="box">
						<view style="text-align: center;margin-top: 20px;">
							<image src="../../static/icons/催促.png"
								style="width: 120rpx;margin-top: 5px;margin-left: 4px;" mode="widthFix"></image>
						</view>
						<view style="text-align: center;font-size: 16px;font-weight: bold;margin-top: 10px;">提醒发货成功
						</view>
						<view style="width: 200px;text-align: center;margin-left: 80px;margin-top: 10px;">
							已提醒卖家发货，若你着急要货，建议您直接与卖家沟通</view>
						<view style="display: flex;margin-top: 10px;">
							<button style="background-color: yellow;border-radius: 30px;width: 100%;font-size: 16px;"
								size="mini">联系客服</button>
							<button style="background-color: orange;border-radius: 30px;width: 100%;font-size: 16px;"
								size="mini" @click="closetoggle">我知道了</button>
						</view>
					</view>
				</view>
			</uni-popup>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				items: ['全部订单', '待付款', '待发货', '待收货', '待评价'],
				ordersList: {},
				current: 0,
				user: uni.getStorageSync('xm-user'),
				type: 'bottom',
				labels: [{
						id: 1,
						name: '多系统萎缩'
					},
					{
						id: 2,
						name: '帕金森病'
					},
					{
						id: 3,
						name: '阿尔茨海默病'
					},
					{
						id: 4,
						name: '脑卒中'
					},
				],
			}
		},
		onShow() {
			this.loadOrders()
		},
		methods: {
			goCommentDetail(item, status) {
				uni.navigateTo({
					url: '/pages/commentDetail/commentDetail?medicinesId=' + item.medicinesId
				})
				item.status = status
				this.$request.put('/order/update', item).then(res => {
					if (res.code === '200') {
						this.loadOrders()
					} else {
						this.$message.error(res.msg)
					}
				})
			},
			updatePay(item) {
				this.$request.put('/order/updatePay', item).then(res => {
					if (res.code === '200') {
						uni.showToast({
							icon: 'success',
							title: '付款成功'
						})
						this.status = '待付款'
						this.loadOrders()
					} else {
						this.$message.error(res.msg)
					}
				})
			},
			updateStatus(item, status) {
				item.status = status
				this.$request.put('/order/update', item).then(res => {
					if (res.code === '200') {
						uni.showToast({
							icon: 'success',
							title: '操作成功'
						})
						this.loadOrders()
					} else {
						this.$message.error(res.msg)
					}
				})
			},
			chat(chatId) {
				// 发送第一个请求以获取 chatRoleId1 和 chatRoleId2
				this.$request.post('/chatRole/add', {
					businessId: chatId,
					userId: this.user.id
				}).then(res => {
					if (res.code === '200') {
						// 获取返回的 mapData
						const resultMap = res.data; // resultMap 应该包含 chatRoleId1 和 chatRoleId2
						// 从 resultMap 中提取 ID
						const chatRoleId1 = resultMap.chatRoleId1;
						const chatRoleId2 = resultMap.chatRoleId2;
						// 使用提取的 ID 发送第二个请求
						this.$request.post('/chatGroup/add', {
							chatUserId: chatRoleId1,
							userId: chatRoleId2
						}).then(res => {
							if (res.code === '200') {
								// 请求成功，跳转到聊天页面
								this.$router.push({
									path: '/pages/chatDetail/chatDetail',
									query: {
										chatId: chatId,
										role: 'BUSINESS'
									}
								});
							} else {
								// 显示错误信息
								this.$message.error(res.msg);
							}
						});
					} else {
						// 显示错误信息
						this.$message.error(res.msg);
					}
				});
			},
			addCart(order) {
				let data = {
					num: order.num,
					totalPrice: order.totalPrice,
					businessId: order.businessId,
					medicinesStyleId: order.medicinesStyleId,
					medicinesId: order.medicinesId,
				}
				this.$request.post('/cart/add', data).then(res => {
					if (res.code === '200') {
						uni.showToast({
							icon: 'success',
							title: '加入成功'
						})
					} else {
						this.$message.error(res.msg)
					}
				})
			},
			loadOrders() {
				let status = null;
				switch (this.current) {
					case 0:
						status = null;
						break;
					case 1:
						status = '待付款';
						break;
					case 2:
						status = '待发货';
						break;
					case 3:
						status = '待收货';
						break;
					case 4:
						status = '待评价';
						break;
				}
				this.$request.get(`/order/selectAllOrders/${this.user.id}/${status}`).then(res => {
					this.ordersList = res.data || [];
				});
			},
			goOrderDetail(orderId) {
				uni.navigateTo({
					url: '/pages/orderDetail/orderDetail?orderId=' + orderId
				})
			},
			toggle(type) {
				this.type = type
				// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
				this.$refs.popup.open(type)
			},
			closetoggle() {
				this.$refs.popup.close()
			},
			goComment(orderId) {
				uni.navigateTo({
					url: '/pages/comment/comment?orderId=' + orderId
				})
			},
			changeStatus(orders, status) {
				orders.status = status
				this.$request.put('/orders/update', orders).then(res => {
					if (res.code === '200') {
						uni.showToast({
							icon: 'success',
							title: '操作成功'
						})
						this.load()
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			},
			del() {
				this.$request.del('/orders/delete/' + this.orderId).then(res => {
					if (res.code === '200') {
						uni.showToast({
							icon: 'success',
							title: '操作成功'
						})
						this.load()
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			},
			handleDel(orderId) {
				this.orderId = orderId
				this.$refs.alertDialog.open()
			},
			goDetail(orderId) {
				uni.navigateTo({
					url: '/pages/detail/detail?orderId=' + orderId
				})
			},
			goBusinessDetail(businessId) {
				uni.navigateTo({
					url: '/pages/businessDetail/businessDetail?businessId=' + businessId
				})
			},
			onClickItem(e) {
				if (this.current != e.currentIndex) {
					this.current = e.currentIndex;
					this.loadOrders()
				}

			}
		}
	}
</script>

<style>

</style>